using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace MobileStreams
{
    public partial class frmChannelDetails : Form
    {
        private Channel chanData;


        public frmChannelDetails(Channel pChan)
        {
            InitializeComponent();
            chanData = pChan;
        }

        private void menuitemStart_Click(object sender, EventArgs e)
        {
            frmPlayer frm = new frmPlayer((Stream)cbStreams.SelectedItem);
            frm.ShowDialog();

            this.Close();
            //Process proWMPLayer = new Process();

            //proWMPLayer.StartInfo.FileName = "wmplayer.exe";
            //proWMPLayer.Start();
        }

        private void frmChannelDetails_KeyUp(object sender, KeyEventArgs e)
        {
            //MessageBox.Show(e.KeyCode.ToString());
        }

        private void frmChannelDetails_Load(object sender, EventArgs e)
        {
            lblChannelName.Text = chanData.ChannelName;
            lblDescription.Text = chanData.Description;
            linkLabelURL.Text = chanData.URL;
            
            cbStreams.DataSource = chanData.Streams;

            pictureBox1.Image = new Bitmap(XMLHandling.strAppDir + "\\ChanPics\\" + chanData.ChannelLogo);

            if (cbStreams.Items.Count > 0)
            {
                cbStreams.SelectedIndex = 0;
            }
            else
            {
                menuitemStart.Enabled = false;
            }
        }

        private void cbStreams_SelectedIndexChanged(object sender, EventArgs e)
        {
            Stream selStream = (Stream)cbStreams.SelectedItem;

            lblStreamURL.Text = selStream.URL;
        }

        private void menuitemBack_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}